package com.ncell.cell;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Dmitry
 */
public class AbstractI {
    private float x;
    private float y;
    private float activateCounter = 0;
    private float oarkn;
    private boolean active;
    private final List<PConnection> connections = new ArrayList<>(3);

    public boolean isPermanentI() {
        return false;
    }

    public List<PConnection> getConnections() {
        return connections;
    }

    public void add(PConnection c) {
        connections.add(c);
    }

    public void add(PConnection... connections) {
        for (PConnection c : connections) {
            this.connections.add(c);
        }
    }

    public void add(List<PConnection> connections) {
        for (PConnection c : connections) {
            this.connections.add(c);
        }
    }

    public void addPs(List<P> ps) {
        for (P p : ps) {
            this.connections.add(new PConnection(p));
        }
    }

    public PConnection remove(int index) {
        return connections.remove(index);
    }

    public void setActive(boolean active) {
        this.active = active;
    }

    public boolean isActive() {
        return active;
    }

    public float getOarkn() {
        return oarkn;
    }

    public void setOarkn(float oarkn) {
        this.oarkn = oarkn;
    }

    public boolean isActiveByOarkn() {
        return oarkn > 0.8f;
    }

    public float getX() {
        return x;
    }

    public void setX(float x) {
        this.x = x;
    }

    public float getY() {
        return y;
    }

    public void setY(float y) {
        this.y = y;
    }

    public float getActivateCounter() {
        return activateCounter;
    }

    public void setActivateCounter(float activateCounter) {
        if (activateCounter >= 99999999999f) {
            activateCounter = 99999999999f;
        }
        this.activateCounter = activateCounter;

    }

    @Override
    public String toString() {
        return "active=" + isActive() + ";oarkn=" + getOarkn() + ";activationCounter=" + getActivateCounter();
    }
}
